module.exports   C
last analyzed

Complexity

Conditions 7
Paths 7

Size

Total Lines 129

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 7
nc 7
nop 2
dl 0
loc 129
rs 6.4589
c 0
b 0
f 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
/**
2
 * Grunt configuration file.
3
 *
4
 * @package WordPoints
5
 * @since 2.1.0
6
 */
7
8
/* jshint node:true */
9
module.exports = function( grunt ) {
10
11
	// Load the default configuration from the dev-lib.
12
	require( './dev-lib/grunt/modules/configure.js' )( grunt, __dirname );
13
14
	// Project configuration.
15
	grunt.config(
16
		[ 'autoloader', 'all', 'filter' ]
17
		, function ( class_files, class_dir ) {
18
19
			if ( 'src/components/points/classes/' === class_dir ) {
20
21
				// This class needs to come before other entity restriction classes.
22
				class_files.splice(
23
					class_files.indexOf( 'logs/viewing/restrictioni.php' ) + 1
24
					, 0
25
					, class_files.splice(
26
						class_files.indexOf( 'logs/viewing/restriction/read/post.php' )
27
						, 1
28
					)[0]
29
				);
30
31
				return class_files;
32
33
			} else if ( 'src/classes/' !== class_dir ) {
34
				return class_files;
35
			}
36
37
			var entity_parents = [],
38
				action_parents = [];
39
40
			// Extract the parent class files. To do that we need to loop
41
			// backwards so that we can remove elements from the array as we go.
42
			for ( var i = class_files.length - 1; i >= 0; i-- ) {
43
44
				if ( class_files[ i ].substr( 0, 14 ) === 'entity/stored/' ) {
45
46
					entity_parents.push( class_files[ i ] );
47
					class_files.splice( i, 1 );
48
49
				} else if ( class_files[ i ].substr( 0, 19 ) === 'entity/relationship' ) {
50
51
					entity_parents.push( class_files[ i ] );
52
					class_files.splice( i, 1 );
53
54
				} else if ( class_files[ i ].substr( 0, 21 ) === 'hook/action/post/type' ) {
55
56
					action_parents.push( class_files[ i ] );
57
					class_files.splice( i, 1 );
58
				}
59
			}
60
61
			// Entity these entity classes need to come before other entity classes.
62
			Array.prototype.splice.apply(
63
				class_files
64
				, [ class_files.indexOf( 'entity.php' ) + 1, 0 ]
65
					.concat( entity_parents.reverse() )
66
			);
67
68
			// Entityish class needs to come before the entity classes.
69
			class_files.splice(
70
				class_files.indexOf( 'entity.php' )
71
				, 0
72
				, class_files.splice(
73
					class_files.indexOf( 'entityish.php' )
74
					, 1
75
				)[0]
76
			);
77
78
			// This class needs to come before other entity restriction classes.
79
			class_files.splice(
80
				class_files.indexOf( 'entity/restrictioni.php' ) + 1
81
				, 0
82
				, class_files.splice(
83
					class_files.indexOf( 'entity/restriction/post/status/nonpublic.php' )
84
					, 1
85
				)[0]
86
			);
87
88
			// Action classes that need to come before other action classes.
89
			Array.prototype.splice.apply(
90
				class_files
91
				, [ class_files.indexOf( 'hook/action.php' ) + 1, 0 ]
92
					.concat( action_parents.reverse() )
93
			);
94
95
			// This class needs to come before other event classes.
96
			class_files.splice(
97
				class_files.indexOf( 'hook/event.php' ) + 1
98
				, 0
99
				, class_files.splice(
100
					class_files.indexOf( 'hook/event/dynamic.php' )
101
					, 1
102
				)[0]
103
			);
104
105
			// The breaking updater extends the un/installer class.
106
			class_files.splice(
107
				class_files.indexOf( 'un/installer/base.php' )
108
				, 0
109
				, class_files.splice(
110
					class_files.indexOf( 'breaking/updater.php' )
111
					, 1
112
				)[0]
113
			);
114
115
			class_files.splice(
116
				class_files.indexOf( 'extension/server/api/extension/license/renewablei.php' ) + 1
117
				, 0
118
				, class_files.splice(
119
					class_files.indexOf( 'extension/server/api/extension/license/renewable/urli.php' )
120
					, 1
121
				)[0]
122
			);
123
124
			// Move the module installer before the upgrader (which extends it).
125
			class_files.splice(
126
				class_files.indexOf( 'extension/upgrader.php' )
127
				, 0
128
				, class_files.splice(
129
					class_files.indexOf( 'module/installer.php' )
130
					, 1
131
				)[0]
132
			);
133
134
			// Move the routine class before the classes that extend it.
135
			class_files.splice(
136
				class_files.indexOf( 'routinei.php' ) + 1
137
				, 0
138
				, class_files.splice(
139
					class_files.indexOf( 'routine.php' )
140
					, 1
141
				)[0]
142
			);
143
144
			return class_files;
145
		}
146
	);
147
};
148
149
// EOF
150